#include <stdlib.h>
#include <iostream>
#include "PopupServer.hpp"
#include <PopupSqlite3Database.hpp>

using namespace std;
using namespace Popup;
using namespace PopupUtils;

int main(int argc, char *argv[])
{
  int port = 2001;
  int nbMaxConnections = 512;

  MaquiServer _svrui("./popup_svr/rc");
  PopupSqlite3Database _dbmgr("./popup_svr/db/popup.sqlite");

  if (argc > 1) {
    info("Server port is %s", argv[1]);
    port = atoi(argv[1]);
  }
  if (argc > 2) {
    info("Max nb connections allowed is %s", argv[2]);
    nbMaxConnections = atoi(argv[2]);
  }

  Server *_svr = Server::newServer(port, nbMaxConnections, &_dbmgr, &_svrui);
  if (_svr != 0)
  {
    _svr->run();
  }

  info("Server exited");

  return 0;
}
